#!/usr/bin/awk -f

# Scrub all repeat user IDs from the input and send the list of
# non-repeats to the output.


BEGIN {
  # *** Symbolic constants ***
  PASSWD_FILE = "/etc/passwd";

  while ((getline line < PASSWD_FILE) > 0) {
    split(line, fields, ":");
    if (fields[3] >= 500) # uid
      whiteList[fields[1]] = fields[1];
  }
  close(PASSWD_FILE);
} # BEGIN


!/#/ && !/^$/ {
  if (!($1 in whiteList))
    list[$1] = $1;
}


END {
  print "# LogCop configuration file.  Watch list of";
  print "# invalid logon IDs.";

  for (userID in list)
    print userID;
} # END 

